import request from '@/util/request'
import store from '@/vuex/store'

export function getRoleList() {
    return request({
        url: "role/getRoleList.do", method: 'post',
        data: {
            token: store.getters.token
        }
    })
}

export function getRoleListPageApi(list) {
    return request({
        url: "role/getRoleListPage.do", method: 'post',
        data: {
            token: store.getters.token,
            pageSize: list.pageSize,
            currentPage: list.currentPage
        }
    })
}

export function addRole(roleDetail) {
    return request({
        url: "role/addRole.do",
        method: 'post',
        data: {
            token: store.getters.token,
            roleDetail: JSON.stringify(roleDetail),
        }
    })
}

export function removeRole(id) {
    const value = {
        appKey: '',
        appFlag: 2,
        token: store.getters.token,
        versionCode: 0,
        param: JSON.stringify(id)
    }
    return request({
        url: "role/removeRole.do",
        method: "post",
        data: value
    })
}

export function getRoleMenu(rid) {
    const value = {
        appKey: '',
        appFlag: 2,
        token: store.getters.token,
        versionCode: 0,
        param: JSON.stringify(rid)
    }
    return request({
        url: "role/getRoleMenu.do",
        method: "post",
        data: value
    })
}

export function changeRoleMenu(roleMenuInfo) {
    const value = {
        appKey: '',
        appFlag: 2,
        token: store.getters.token,
        versionCode: 0,
        param: JSON.stringify(roleMenuInfo)
    }
    return request({
        url: "role/changeRoleMenu.do",
        method: "post",
        data: value
    })
}